package tcpsocket;


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * 1.创建客户端 必须指定服务器端+端口 此时就在连接
 * 2.接收数据+发送数据
 */
public class Client {
    public static void main(String[] args) {
        try {
            //1.创建客户端 必须指定服务器端+端口 此时就在连接
            Socket client=new Socket("localhost",8080);
            //2.接受数据
            //输入流
            /*
            InputStreamReader isr=new InputStreamReader(client.getInputStream());
            BufferedReader br=new BufferedReader(isr);
            String str=br.readLine();
            System.out.println(str);

             */
            DataInputStream dis=new DataInputStream(client.getInputStream());
            String msg=dis.readUTF();
            System.out.println(msg);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
